Skip to content

Fix: Skip host LLVM detection during cross-compilation#241

Merged
LunaStev merged 1 commit intowavefnd:masterfrom
LunaStev:build/buildrs_bugfix
Nov 27, 2025
Merged

Fix: Skip host LLVM detection during cross-compilation#241
LunaStev merged 1 commit intowavefnd:masterfrom
LunaStev:build/buildrs_bugfix

Conversation

@LunaStev
Copy link
Member

This PR resolves build failures encountered during cross-compilation (e.g., building Windows binaries on a Linux host) by preventing the build script from linking against the host's system libraries.

Problem

The build.rs script executes on the host machine during the build process. Previously, it would detect the host's system LLVM libraries (e.g., /usr/lib/llvm-14 on Linux) and instruct Cargo to link them into the target binary (e.g., a Windows .exe). This resulted in linker errors due to mismatched binary formats and architectures.

Solution

  • Added a check in llvm_temporary/build.rs to compare the TARGET and HOST environment variables.
  • If TARGET != HOST (indicating cross-compilation), the script now prints a warning and skips the automatic system LLVM detection logic.
  • This ensures that the cross-linker does not attempt to link against incompatible host libraries.

When cross-compiling (e.g., building for Windows on Linux), `build.rs` runs on the host machine. Previously, it would detect and attempt to link the host's system LLVM libraries against the target binary, causing linker errors.

This change adds a check to compare the `TARGET` and `HOST` environment variables. If they differ, automatic LLVM detection is skipped to prevent incorrect linking configurations, assuming the cross-compilation toolchain handles dependencies appropriately.
@LunaStev LunaStev self-assigned this Nov 27, 2025
@LunaStev LunaStev merged commit 3760907 into wavefnd:master Nov 27, 2025
2 checks passed
@LunaStev LunaStev deleted the build/buildrs_bugfix branch December 13, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant